/*
 * @Author: chentao 
 * @Date: 2021-01-23 10:35:16 
 * @Last Modified by: chentao
 * @Last Modified time: 2022-05-13 13:54:44
 * 
 */

interface IPerson{
     iName:string;
     iAge:number;
}

class Person implements IPerson{

    iAge: number;
    iName: string;

    private name: string;
    private age: number;
   
    public f:(name:string)=> void;

    public constructor(name: string, age: number) {
        this.name = name;
        this.age = age;
        console.log(this.name,this.age)
    }
    run(): void {
        console.log('this.name', this.name)
    }
    
    public get getName():string{
        return this.name;
    }
    //ts的set跟get方法
    set setName(name:string){
        this.name = name;
    }
}

class Student extends Person{
    public constructor(name: string, age: number) {
        super(name,age);
    }
}

var p=new Person('张三',23)
p.run()
console.log("输出name",p.getName);
p.setName ="李四";
console.log("输出setName",p.getName)

//创建Student对象
var student= new Student("student",33);
console.log("student.getName:",student.getName);
student.f = (name)=>{
     console.log(`${name}函数调用`)
}
student.f("RNG")

function testInterface(iPerson:IPerson):IPerson{
    console.log("iPerson",iPerson)
    return iPerson
}

let iPerson:IPerson=testInterface(student)
console.log(iPerson instanceof Student)
console.log(iPerson instanceof Person)
